﻿using System.Collections.Generic;
//
using PerceptiveMCAPI.Types;

namespace PerceptiveMCAPI_Test
{
   public partial class sub_SegmentOptions : System.Web.UI.UserControl
   {
      public string Match
      {
         get { return ddlConditionMatch.SelectedValue; }
         set { ddlConditionMatch.SelectedValue = value; }
      }

      public List<campaignSegmentCondition> SegmentConditions
      {
         get { return getSegmentConditions(); }
      }
      // ----------------------------
      public void Setup()
      {
         this.Visible = true;
         txtField01.Focus();
      }
      // ----------------------------------------------------
      private List<campaignSegmentCondition> getSegmentConditions()
      {
         List<campaignSegmentCondition> segments = new List<campaignSegmentCondition>();
         for ( int i = 1; i <= 10; i++ )
         {
            campaignSegmentCondition segment = new campaignSegmentCondition();
            string field = ""; string op = ""; string value = ""; string extra = "";
            switch ( i )
            {
               case 1:
                  field = txtField01.Text.Trim(); op = txtOp01.Text.Trim(); value = txtValue01.Text.Trim(); extra = txtExtra01.Text.Trim();
                  break;
               case 2:
                  field = txtField02.Text.Trim(); op = txtOp02.Text.Trim(); value = txtValue02.Text.Trim(); extra = txtExtra02.Text.Trim();
                  break;
               case 3:
                  field = txtField03.Text.Trim(); op = txtOp03.Text.Trim(); value = txtValue03.Text.Trim(); extra = txtExtra03.Text.Trim();
                  break;
               case 4:
                  field = txtField04.Text.Trim(); op = txtOp04.Text.Trim(); value = txtValue04.Text.Trim(); extra = txtExtra04.Text.Trim();
                  break;
               case 5:
                  field = txtField05.Text.Trim(); op = txtOp05.Text.Trim(); value = txtValue05.Text.Trim(); extra = txtExtra05.Text.Trim();
                  break;
               case 6:
                  field = txtField06.Text.Trim(); op = txtOp06.Text.Trim(); value = txtValue06.Text.Trim(); extra = txtExtra06.Text.Trim();
                  break;
               case 7:
                  field = txtField07.Text.Trim(); op = txtOp07.Text.Trim(); value = txtValue07.Text.Trim(); extra = txtExtra07.Text.Trim();
                  break;
               case 8:
                  field = txtField08.Text.Trim(); op = txtOp08.Text.Trim(); value = txtValue08.Text.Trim(); extra = txtExtra08.Text.Trim();
                  break;
               case 9:
                  field = txtField09.Text.Trim(); op = txtOp09.Text.Trim(); value = txtValue09.Text.Trim(); extra = txtExtra09.Text.Trim();
                  break;
               case 10:
                  field = txtField10.Text.Trim(); op = txtOp10.Text.Trim(); value = txtValue10.Text.Trim(); extra = txtExtra10.Text.Trim();
                  break;
            }
            //
            if ( !string.IsNullOrEmpty( field ) )
            {
               segment.field = field;
               segment.op = op;
               segment.value = value;
               segment.extra = extra;
               segments.Add( segment );
            }
         }
         return segments;
      }
   }
}